import cv2
import matplotlib.pyplot as plt
import numpy as np

def main():
    img = cv2.imread('6/1.bmp') 
    # img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    plt.imshow(img)
    plt.show()
    if img is not None:
        height, weight = img.shape[0:2]
        img1_locate = np.float32([[145, 45],
                                  [410, 45],
                                  [50, 465],
                                  [316,465]])
        img2_locate = np.float32([[50, 50],
                                  [50, 300],
                                  [300, 50],
                                  [300, 300]])
        M = cv2.getPerspectiveTransform(img1_locate, img2_locate)
        dst = cv2.warpPerspective(img, M, (weight, height))

        cv2.imshow('result', dst)
        cv2.imshow('img', img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()

if __name__ == '__main__':
    main()